# -*- coding: utf-8 -*-
from selenium import webdriver
import unittest, time

class TestCSDN(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
#        self.driver = webdriver.Firefox()
#        self.driver = webdriver.Firefox()
        self.base_url = "http://blog.csdn.net/testMiaozhen"
        self.verificationErrors = []
    
    def test_CSDN(self):
        driver = self.driver
        driver.get(self.base_url + "/")
        driver.maximize_window()
        driver.find_element_by_xpath("//a[contains(text(),'登录')]").click()
        driver.switch_to_frame("logfrm")        
        
        driver.find_element_by_id("u").clear()
        driver.find_element_by_id("u").send_keys("testMiaozhen")
        driver.find_element_by_id("p").clear()
        driver.find_element_by_id("p").send_keys("miaozhen")
        
        driver.find_element_by_xpath("//a[@id='aLogin']/span").click()
        print '登录成功'
        
#        driver.find_element_by_xpath("//span[contains(text(),'写新文章')]").click()        
        time.sleep(15)        
        driver.quit()

if __name__ == "__main__":
    unittest.main()
